# -*- coding: utf-8 -*-
import os
from ippool.lib.plogging import Plog
# 调试模式是否开启
DEBUG = True

SECRET_KEY = 'ty@puton.info'

logFormatDict = {
        'standard_format': '[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]' \
                           '[%(levelname)s][%(message)s]',  # 其中name为getlogger指定的名字
        'simple_format': '[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d]%(message)s',
        'id_simple_format': '[%(levelname)s][%(asctime)s] %(message)s',
        'simple_format_info': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    }

try:
    PROFILE = os.environ["SPD_PROFILE"]
except Exception as e:
    PROFILE = 'dev'

if PROFILE == 'dev':
    ip_source_url = 'http://www.xicidaili.com/nn/%d'
    gen_ippool_dir = r'D:\iProject\myPython\com\teradata\ippool\get_check'
    map_ip_file_prefix = 'proxy_list_{}{}'
    check_ip_file_prefix = 'check_ip_{}'
    ping_url = 'http://www.baidu.com'

    loggerLevel = 'DEBUG:INFO'
    loggerFormat = 'standard_format'
    loggerDir = r'D:\iProject\myPython\com\teradata\ippool\logs'
    loggerFileName = 'make_ip_pool.log'
    logFileName = loggerDir + os.sep + loggerFileName
    log = Plog()
    log.set_logger(when='D', limit=1, level=loggerLevel, filename=logFileName, mode='w', fmt=logFormatDict[loggerFormat])
    log = log.get_logger_instance()

elif PROFILE == 'prod':
    ip_source_url = 'http://www.xicidaili.com/nn/%d'
    gen_ippool_dir = r'D:\iProject\myPython\com\teradata\ippool\get_check'
    map_ip_file_prefix = 'proxy_list_{}{}'
    check_ip_file_prefix = 'check_ip_{}'
    ping_url = 'http://www.baidu.com'

    loggerLevel = 'DEBUG:INFO'
    loggerFormat = 'standard_format'
    loggerDir = r'D:\iProject\myPython\com\teradata\ippool\logs'
    loggerFileName = 'make_ip_pool.log'
    logFileName = loggerDir + os.sep + loggerFileName
    log = Plog()
    log.set_logger(when='D', limit=1, level=loggerLevel, filename=logFileName, mode='w', fmt=logFormatDict[loggerFormat])
    log = log.get_logger_instance()


if __name__ == '__main__':
    # print(PROFILE)
    # print(data_json_dir)
    # log.info("test_setting_log")
    # print(logFileName)
    # file = __file__
    # print(file)
    # abs_file = os.path.abspath(file)
    # print(abs_file)
    # dir_file = os.path.dirname(abs_file)
    # print(dir_file)
    tb = u'tablename'
    db = u'databasename'
    # log.info('删除hive临时表:%s.%s', tb, db)

    num = 0

    lst = [tb, db, num]
    args = tuple(lst)
    print(args)
    ntplst = [e.encode('utf-8') if ['str', 'unicode'].__contains__(type(e).__name__) else e for e in args]
    print(ntplst)


    # s = 'abc'
    # print(type(s))
    # if type(s).__name__ == 'str':
    #     print(1)
    # else:
    #     print(2)

    # ls = ['str', 'unicode']
    # print(ls.__contains__('uniacode'))

